package com.ccoffers.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.ccoffers.model.cardinfo.CreditCardCompany;
import com.ccoffers.model.cardinfo.CreditCardType;
import com.ccoffers.model.shopping.Merchant;
import com.ccoffers.model.shopping.ShoppingCategory;
import com.ccoffers.service.impl.CRUDServiceImpl;

@Controller
public class DefaultAdminPageController {
	@Autowired
	private CRUDServiceImpl<CreditCardType> creditCardTypeService;
	
	@Autowired
	private CRUDServiceImpl<CreditCardCompany> creditCardCompanyService;
	@Autowired
	private CRUDServiceImpl<Merchant> merchantService;
	@Autowired
	private CRUDServiceImpl<ShoppingCategory> shoppingCategoryService;
	@RequestMapping(value="/internal/admin")
	public String showAdminPage(Model model){
		model.addAttribute("cardTypes", creditCardTypeService.loadAll(CreditCardType.class));
		model.addAttribute("cardCompanies", creditCardCompanyService.loadAll(CreditCardCompany.class));
		model.addAttribute("merchants", merchantService.loadAll(Merchant.class));
		model.addAttribute("shoppingCategories", shoppingCategoryService.loadAll(ShoppingCategory.class));
		return JspNames.OFFER_COMPONENTS_ADMIN;
	}
}
